<template>
  <view class="container">
    <view class="flex item">
      <view class="lable">知识类目</view>
      <view class="value">{{ knowledge.categoryName }}</view>
    </view>
    <view class="flex item">
      <view class="lable">知识标题</view>
      <view class="value">{{ knowledge.title }}</view>
    </view>
    <view class="item">
      <view class="lable">知识内容</view>
      <view class="mpvalue">
        <mp-html :content="knowledge.content" />
      </view>
    </view>
    <view class="submit" v-if="status == 'sumbit'">提交</view>
  </view>
</template>
<script>
import { getknowledge, getknowledgetemporary } from "@/common/api/knowledge";
export default {
  data() {
    return {
      knowledgeId: "",
      knowledgeTemporaryId: "",
      knowledge: {},
      status: "",
    };
  },
  onShow() {
    if (this.status !== "add") {
      this.getInfo();
    }
  },
  onLoad(options) {
    this.knowledgeId = options.knowledgeId;
    this.knowledgeTemporaryId = options.knowledgeTemporaryId;
    this.status = options.status;
  },
  methods: {
    async getInfo() {
      try {
        uni.showLoading({ mask: true, title: "加载中" });
        let res;
        if (this.knowledgeTemporaryId) {
          res = await getknowledgetemporary(this.knowledgeTemporaryId);
        } else {
          res = await getknowledge(this.knowledgeId);
        }
        uni.setNavigationBarTitle({
          title: res.data.title,
        });
        this.knowledge = res.data;
      } finally {
      }
    },
  },
};
</script>
  <style lang="scss" scoped>
.submit {
  @include btn_plain(#ffffff, #f85415) {
    left: 32rpx;
    bottom: env(safe-area-inset-bottom);
    position: fixed;
    width: 686rpx;
    height: 88rpx;
    background: #ffffff;
    box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(129, 129, 129, 0.2);
    border-radius: 44rpx;
    border: 1rpx solid rgba(255, 72, 0, 0.54);
    font-size: 28rpx;
    font-family: PingFangSC, PingFang SC;
    font-weight: 600;
    line-height: 88rpx;
  }
}
.container {
  padding: 32rpx;
  box-sizing: border-box;
  background: #fafafa;
  min-height: 100vh;
  .item {
    margin-bottom: 40rpx;
    .lable {
      font-size: 28rpx;
      font-family: PingFangSC, PingFang SC;
      font-weight: 400;
      color: #666666;
      line-height: 40rpx;
    }
    .value {
      margin-left: 24rpx;
      width: 550rpx;
      font-size: 28rpx;
      font-family: PingFangSC, PingFang SC;
      font-weight: 400;
      color: #333333;
      line-height: 40rpx;
    }
    .mpvalue {
      margin-top: 16rpx;
      width: 686rpx;
      font-size: 28rpx;
      font-family: PingFangSC, PingFang SC;
      font-weight: 400;
      color: #333333;
      line-height: 40rpx;
    }
  }
}
</style>